<template>
    <div class="workshops_container">
      <dv-loading v-if="loading"></dv-loading>
      <table-header  :name="title" icon="splotch"/>
      <div class="workshops_main">
        <div class="main_left">
          <div class="main_left_top">
            <div class="main_left_top_item" v-for="(item,index) in signArray" :key="index">
              <lefttop :real="real" :sign="item.mark"/>
            </div>
          </div>
          <div class="main_left_bottom">
              <leftbottom :real="real"/>
          </div>
        </div>
        <div class="main_right">
          <div class="main_right_top">
              <righttop :real="real"/>
          </div>
          <div class="main_right_bottom">
            <rightbottom :real="real"/>
          </div>
        </div>
      </div>
  </div>
</template>
<script>
import TableHeader from "../../components/tableHeader/index"
import lefttop from "../components/flotation/leftTop"
import leftbottom from "../components/flotation/leftBottom"
import righttop from "../components/flotation/rightTop"
import rightbottom from "../components/flotation/rightBottom"
export default {
  components:{
    TableHeader,
    lefttop,
    leftbottom,
    righttop,
    rightbottom
  },
  data() {
    return {
      loading: true,
      real:{},
      title:"浮选",
      signArray:[]
    };
  },
  sockets:{
    connect:function(data) {
      console.log("连接connect",data)
      this.createSocket()
    },
    reconnect(data){
      console.log("重新连接",data)
      // this.$sockets.emit("connect",1)
      this.$socket.connect()
    },
    disconnect(){
      console.log("socket已断开连接")
    },
    fxdata(data){
      var temp=JSON.parse(data).fxdata[0]
      this.real=temp
      console.log(this.real,'message')
      if(this.real){
        this.signArray=[]
        for(var key in this.real){
          if(key.indexOf("_fk16") != -1){
            this.signArray.push({
              mark:key.slice(3,6)
            })
          }
        }
        this.loading = false;
      }
    },
  },
  beforeDestroy(){
   this.$socket.close()
  },
  mounted() {
    this.createSocket()
  },
  methods: {
    //创建socket链接
    createSocket(){
      this.$socket.connect()
      this.$socket.emit('fxdata', { subscribe: true })
    }
  },
};
</script>
<style lang="scss" scoped>
.workshops_main{
  width:100%;
  display: flex;
  justify-content: space-between;
  align-items: top;
  padding: 0 0.3rem;
  overflow: hidden;
  box-sizing: border-box;
}
.main_left{
  width: 80%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-direction: column;
}
.main_left_top{
  width: 100%;
  height: 78%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}
.main_left_top_item{
  width: 100%;
  height: calc(100% / 4.2);
}
.main_left_bottom{
  width: 100%;
  height: 20.5%;
  overflow: hidden;
}
.main_right{
  width: 19%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.1rem;
}
.main_right_top{
  width:100%;
  height: 65%;
}
.main_right_bottom{
  width:100%;
  height: 33%;
}
</style>
